package com.kavysoft.prueba;

import java.util.ArrayList;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ListView;
import android.widget.Toast;

import com.kavysoft.cliente.ClientMSG;


public class MainActivity extends Activity {

	private DrawerLayout NavDrawerLayout;
	private ListView NavList;
    public ClientMSG clientMSG;
	int myID;

	
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.activity_main);
	    NavDrawerLayout =(DrawerLayout) findViewById(R.id.drawer_layout);
	    NavList = (ListView) findViewById(R.id.navigation_list);

	    ListView listview = (ListView) findViewById(R.id.listView);
	    ListAdapter customListAdapter;
	    ArrayList<ItemGrid> gridArray = new ArrayList<ItemGrid>();
	    ArrayList<ItemGrid> gridArray2 = new ArrayList<ItemGrid>();
	    ArrayList<ItemGrid> gridArray3 = new ArrayList<ItemGrid>();
	    ArrayList<ItemGrid> gridArray4 = new ArrayList<ItemGrid>();
	    
	    Bitmap sample0 = BitmapFactory.decodeResource(this.getResources(), R.drawable.foco_on);
	  	Bitmap sample1 = BitmapFactory.decodeResource(this.getResources(), R.drawable.aire_on);
	  	Bitmap sample2 = BitmapFactory.decodeResource(this.getResources(), R.drawable.proyector_on);
	  	
	  	Bitmap sample3 = BitmapFactory.decodeResource(this.getResources(), R.drawable.foco_off);
	  	Bitmap sample4 = BitmapFactory.decodeResource(this.getResources(), R.drawable.aire_off);
	  	Bitmap sample5 = BitmapFactory.decodeResource(this.getResources(), R.drawable.proyector_off);
	  	
	  		
	  	gridArray.add(new ItemGrid(sample0,sample3,"sample 0","2",true));
	  	gridArray.add(new ItemGrid(sample1,sample4,"sample 1","4",true));
	  	gridArray.add(new ItemGrid(sample2,sample5,"sample 2","6",true));
	  	
	  	gridArray2.add(new ItemGrid(sample0,sample3,"sample 0","8",true));
	  	gridArray2.add(new ItemGrid(sample1,sample4,"sample 1","10",true));
	  	gridArray2.add(new ItemGrid(sample2,sample5,"sample 2","12",true));
	  	
	  	gridArray3.add(new ItemGrid(sample0,sample3,"sample 0","14",true));
	  	gridArray3.add(new ItemGrid(sample1,sample4,"sample 1","16",true));
	  	gridArray3.add(new ItemGrid(sample2,sample5,"sample 2","18",true));
	  	
	  	gridArray4.add(new ItemGrid(sample0,sample3,"sample 0","20",true));
	  	gridArray4.add(new ItemGrid(sample1,sample4,"sample 1","22",true));
	  	gridArray4.add(new ItemGrid(sample2,sample5,"sample 2","24",true));

	  	ArrayList<ItemList> listArray = new ArrayList<ItemList>();
	  	
	  	listArray.add(new ItemList("Class 1", "Subclass 1", gridArray));
	  	listArray.add(new ItemList("Class 2", "Subclass 2", gridArray2));
	  	listArray.add(new ItemList("Class 3", "Subclass 3", gridArray3));
	  	listArray.add(new ItemList("Class 4", "Subclass 4", gridArray4));
	  	
	  	customListAdapter = new ListAdapter(this, R.layout.list_layout,listArray, this);
	  	listview.setAdapter(customListAdapter);
	  	
	    clientMSG = new ClientMSG("192.168.0.187", 3051, this); //Change here the IP and Port for your Server IP and Port
		myID = clientMSG.getId();
	}


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    	int id = item.getItemId();
    	
    	switch (id) {
		case R.id.action_search:
				Toast.makeText(getBaseContext(),"click :)",Toast.LENGTH_SHORT).show();
				return true;
		default:
			break;
		}

        return super.onOptionsItemSelected(item);
    }
}
